package cn.itsource.org.mapper;

import cn.itsource.org.domain.User;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

public interface UserMapper extends Mapper<User> {

    //基础的crud全部都是通过继承得到

    //通过手机号查询
    default User findByPhone(String phone){

        //查询条件
        Example example = new Example(User.class);
        example.and().andEqualTo("phone",phone);
        //查询
        return this.selectOneByExample(example);
    }

    default User findUser(String username){
        //查询条件
        Example example = new Example(User.class);
        example.or().orEqualTo("phone",username)
                .orEqualTo("email",username)
                .orEqualTo("username",username);

        //查询
        return this.selectOneByExample(example);
    }
}
